<template>
	<view>
		<view class="item" v-for="(item, index) in list" :key="index">
			<text>{{ item.address }}</text>
			<image src="../../static/enid.png" @click="enid(item.id)"></image>
		</view>
		<button class="btn" @click="toadd">添加地址</button>
	</view>
</template>

<script lang="ts" setup>
import { api } from '@/api/store_api';
import { get, err, to } from '@/utils/uniapi';
import { onLoad } from '@dcloudio/uni-app';
import { ref } from 'vue';
const mchMemberNo = get('user').mchMemberNo;
const list = ref<any>([]);
async function getlist() {
	try {
		const { respCode, source } = await api.addressList({ mchMemberNo });
		if (respCode === 200) {
			list.value = JSON.parse(source);
			console.log(list.value);
		}
	} catch (e) {
		err(e);
	}
}
function enid(e: string) {
	to('/user/Addaddress/Addaddress?id=' + e);
}
function toadd() {
	to('/user/Addaddress/Addaddress');
}
onLoad(() => {
	getlist();
});
</script>

<style scoped lang="scss">
.item {
	width: 690rpx;
	margin: 0 auto;
	background-color: #fff;
	color: #333;
	padding: 20rpx;
	box-sizing: border-box;
	margin-bottom: 10rpx;
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-size: 24rpx;
	image {
		width: 40rpx;
		height: 40rpx;
	}
}
.btn {
	width: 690rpx;
	background-color: #c32136;
	color: #ffffff;
	position: fixed;
	bottom: 10rpx;
	left: 50%;
	transform: translateX(-50%);
}
</style>
